package project.student_info_manage;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * description: 数据库工具类
 * author: xiaoxu
 * createTime: 2018-12-05 11:43
 **/
public class DbUtil {

    private static final String URL =
            "jdbc:mysql://39.105.44.223:3306/ZhangXu?useUnicode=true&amp;characterEncoding=utf-8";
    private static final String USER = "dbadmin";
    private static final String PASSWORD = "dbadmin";
    private static Connection conn = null;

    static {
        try {
            //1.加载驱动程序
            Class.forName("com.mysql.jdbc.Driver");
            //2.获得数据库连接
            conn = DriverManager.getConnection(URL, USER, PASSWORD);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public static Connection getConnection() {
        return conn;
    }

}
